home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / Programming / PPCSmallEiffel / lib_se / run_feature_5.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  3.8 KB  |  155 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  4. --                       http://www.loria.fr/SmallEiffel
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it 
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later 
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License 
  11. -- for  more  details.  You  should  have  received a copy of the GNU General 
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class RUN_FEATURE_5
  17.    
  18. inherit RUN_FEATURE redefine base_feature end;
  19.  
  20. creation {ONCE_PROCEDURE} make
  21.    
  22. feature 
  23.    
  24.    base_feature: ONCE_PROCEDURE;
  25.       
  26.    local_vars: LOCAL_VAR_LIST;      
  27.          
  28.    is_static: BOOLEAN is false;
  29.    
  30.    static_value_mem: INTEGER is do end;
  31.  
  32.    can_be_dropped: BOOLEAN is false;
  33.    
  34.    is_pre_computable: BOOLEAN is false;
  35.    
  36.    afd_check is
  37.       do
  38.      routine_afd_check;
  39.       end;
  40.  
  41.    mapping_c is
  42.       do
  43.      if use_current then
  44.         default_mapping_procedure;
  45.      else
  46.         if cpp.target_cannot_be_dropped then
  47.            cpp.put_string(fz_14);
  48.         end;
  49.         mapping_name;
  50.         cpp.put_character('(');
  51.         if arg_count > 0 then
  52.            cpp.put_arguments;
  53.         end;
  54.         cpp.put_string(fz_14);
  55.      end;
  56.       end;
  57.    
  58.    c_define is
  59.       local
  60.      bfbc: BASE_CLASS;
  61.       do
  62.      bfbc := base_feature.base_class;
  63.      if not bfbc.once_flag(once_mark) then
  64.         once_boolean;
  65.      end;
  66.      define_prototype;
  67.      cpp.put_string("if (");
  68.      once_flag; 
  69.      cpp.put_string("==0){%N");
  70.      define_opening;
  71.      once_flag;
  72.      cpp.put_string("=1;%N");     
  73.      if routine_body /= Void then
  74.         routine_body.compile_to_c;
  75.      end;
  76.      define_closing;
  77.      cpp.put_string("}}%N");
  78.       end;
  79.    
  80. feature {NONE}   
  81.    
  82.    initialize is
  83.       do
  84.      arguments := base_feature.arguments;
  85.      if arguments /= Void and then arguments.count > 0 then
  86.         arguments := arguments.to_runnable(current_type);
  87.      end;
  88.      local_vars := base_feature.local_vars;
  89.      if local_vars /= Void and then local_vars.count > 0 then
  90.         local_vars := local_vars.to_runnable(current_type);
  91.      end;
  92.      routine_body := base_feature.routine_body;
  93.      if routine_body /= Void then
  94.         routine_body := routine_body.to_runnable(current_type);
  95.      end;
  96.      if run_control.require_check then
  97.         require_assertion := base_feature.run_require(Current);
  98.      end;
  99.      if run_control.ensure_check then
  100.         ensure_assertion := base_feature.run_ensure(Current);
  101.      end;
  102.      once_routine_pool.add_procedure(Current);
  103.       end;
  104.    
  105.    compute_use_current is
  106.       do
  107.      std_compute_use_current;
  108.       end;
  109.    
  110. feature {RUN_CLASS}
  111.  
  112.    jvm_field_or_method is
  113.       do
  114.      jvm.add_method(Current);
  115.       end;
  116.  
  117. feature 
  118.  
  119.    mapping_jvm is
  120.       do
  121.      routine_mapping_jvm;
  122.       end;
  123.  
  124. feature {JVM}
  125.  
  126.    jvm_define is
  127.       local
  128.      branch, idx_flag: INTEGER;
  129.       do
  130.      idx_flag := once_routine_pool.idx_fieldref_for_flag(Current);
  131.      method_info_start;
  132.      code_attribute.opcode_getstatic(idx_flag,1);
  133.      branch := code_attribute.opcode_ifne;
  134.      code_attribute.opcode_iconst_1;
  135.      code_attribute.opcode_putstatic(idx_flag,-1);
  136.      jvm_define_opening;
  137.      if routine_body /= Void then
  138.         routine_body.compile_to_jvm;
  139.      end;
  140.      jvm_define_closing;
  141.      code_attribute.resolve_u2_branch(branch);
  142.      code_attribute.opcode_return;
  143.      method_info.finish;
  144.       end;
  145.    
  146. feature {NONE}
  147.  
  148.    update_tmp_jvm_descriptor is
  149.       do
  150.      routine_update_tmp_jvm_descriptor;
  151.       end;
  152.  
  153. end -- RUN_FEATURE_5
  154.  
  155.